<!-- 文章分类通用组件 -->
<script setup>
import articleApi from '@/api/article.js'
import { onMounted, ref } from 'vue'
const channelList = ref([]);
//一进页面就区获取文章分类的类别
onMounted(async () => {
 const res = await articleApi.getMyArticleList();
 channelList.value = res.data.data;
});
// Vue3中: v-model是 :modelValue 和 @update:modelValue的简写
defineProps({
    modelValue:{
        type:[Number,String]
    }
})
const emit = defineEmits(['update:modelValue'])
</script>
<template>
    <el-select 
    style="width: 150px;" 
    :modelValue="modelValue"
    @update:modelValue="emit('update:modelValue',$event)">
          <!-- lable是展示给用户看的，value是提交给后台的值 -->
          <el-option v-for="channel in channelList" 
          :key="channel.id"
          :label="channel.cate_name"
          :value="channel.id"
          ></el-option>
        </el-select>
</template>